package OOAE_UWE.Assessment;

public class StatePattern {
    public static void main(String[] args) {
        // 初始化一个Clean状态的房间
        Room room101 = new Room("101", "Standard", new CleanState());

        // 测试1: Clean → Dirty（允许）
        room101.setState(new DirtyState());

        // 测试2: Dirty → Offline（允许）
        room101.setState(new OfflineState());

        // 测试3: Offline → Clean（应抛出异常）
        try {
            room101.setState(new CleanState());
        } catch (IllegalStateException e) {
            System.out.println(e.getMessage()); // 输出错误信息
        }

        // 测试4: Offline → Dirty（允许）
        room101.setState(new DirtyState());

        // 测试5: Dirty → Clean（允许）
        room101.setState(new CleanState());
        System.out.println("Available for rent status is:" + room101.isAvailableForRent()); // 应为true
    }
}
